#include <bits/stdc++.h>
#define MAXN 100023
using namespace std;
int a[MAXN], n, m;
inline int get_num() {
	int k = 0, f = 1;
	char c = getchar();
	for(; !isdigit(c); c = getchar()) if(c == '-') f = -1;
	for(; isdigit(c); c = getchar()) k = k * 10 + c - '0';
	return k * f;
}
struct segtree{
	int mi[MAXN << 2];
	segtree() {
		memset(mi, 0, sizeof(mi));
	}
	void build(int x, int l, int r) {
		if(l == r) {
			mi[x] = a[l];
			return;
		}
		else {
			int mid = (l + r) >> 1;
			build(x << 1, l, mid);
			build(x << 1 | 1, mid + 1, r);
			mi[x] = min(mi[x << 1], mi[x << 1 | 1]);
		}
	}
	int find(int x, int l, int r, int s, int t) {
		int mid = (l + r) >> 1;
		if(l == s && t == r) return mi[x];
		else if(t <= mid) return find(x << 1, l, mid, s, t);
		else if(s > mid) return find(x << 1 | 1, mid + 1, r, s, t);
		else {
			return min(find(x << 1, l, mid, s, mid), find(x << 1 | 1, mid + 1, r, mid + 1, t));
		}
	}
}T;
int main() {
	freopen("faithful.in", "r", stdin);
	freopen("faithful.out", "w", stdout);
	segtree T;
	m = get_num();
	n = get_num();
	for(int i = 1; i <= m; i++) {
		a[i] = get_num();
	}
	T.build(1, 1, m);
	while(n--) {
		int s = get_num();
		int t = get_num();
		printf("%d ", T.find(1, 1, m, s, t));
	}
}
